home *** CD-ROM | disk | FTP | other *** search
- Path: isonews.bbn.hp.com!hpbblb!news
- From: Matthias Dittrich <matti>
- Newsgroups: comp.lang.c
- Subject: Re: passing arguments to main()
- Date: 4 Mar 1996 08:04:22 GMT
- Organization: Hewlett-Packard Co.
- Message-ID: <4he866$qf2@hpbblb.bbn.hp.com>
- References: <4h78t1$nqq@netnews.upenn.edu>
- NNTP-Posting-Host: trabant.bbn.hp.com
- Mime-Version: 1.0
- Content-Type: text/plain; charset=us-ascii
- Content-Transfer-Encoding: 7bit
- X-Mailer: Mozilla 1.1N (X11; I; HP-UX A.09.07 9000/712)
- X-URL: news:4h78t1$nqq@netnews.upenn.edu
-
- daniels@oasis.rad.upenn.edu (Jamie Daniels) wrote:
- >Hello,
- >
- >I have a question about c I am not very good with programming. I have this
- >project that I want to take two strings one a name the other being an 80
- >character message(sentence). I want it to spit out a simplt print statement at
- >an Unix prompt. But I don't know how to pass arguments to main(). also I can't
- >get the output to be entered in at the unix prompt. I want the output to be a
- >command. for a simple example
- >
- > printf("ping 165.234.323.222");
- >
- >will not ping this address it only prints this statement before the prompt
- >
- This function shouldn't do anything other :-)
-
- But now to your problems, use main as it is defined:
- int main(int argc, char** argv)
- where argc is the number of arguments, argv an array of pointers to the
- arguments. argv[0] is the command name (most your program name).
-
- To execute your command (e.g. ping) use system() or pipe the output of
- your program to a shell.
-
- Good luck,
- Matthias
-
-